
<div class="container-fluid">

            <div class="row-fluid">
                <div class="span12">
                    <h3 class="page-title">
                        学院管理 <small>学院列表</small>
                    </h3>
                    <ul class="breadcrumb">
                        <li>
                            <i class="icon-home"></i>
                            <a href="index.html">学院管理</a> 
                            <i class="icon-angle-right"></i>
                        </li>
                        <li><a href="#">学院列表</a></li>
                      
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            
            
            <div class="row-fluid"> 

                <div class="portlet box blue">
                        <div class="portlet-title">
                                <div class="caption"><i class="icon-cogs"></i>学院列表</div>
                                
                                <div class="tools">
                                        <a href="javascript:;" class="collapse"></a>
				</div>
                                
                                <div class="actions">
                                    <a href="" class="btn green" data-toggle="modal" data-target="#modalAdd" ><i calss="icon-pencil"></i>添加学院</a>
                                </div>  
                                
                             
                        </div>
                    
                       

                    
                    <div class="portlet-body">
                          <?php
            $this->widget('bootstrap.widgets.TbGridView', array(
                'id' => 'table-school',
                'dataProvider' => $School->search(),
                'filter' => $School,
                //'enableHistory' =>'true',
                'afterAjaxUpdate' => 'reinstallDatePicker',
                'htmlOptions' =>array('class'=>'table table-hover'),
                'summaryText' => '<font color="#0066A4"; style="float:right">显示{start}-{end}条.共{count}条记录,当前第{page}页</font>', 
//                'pager'=>array(
//                    'class'=>'CLinkPager',//定义要调用的分页器类，默认是CLinkPager，需要完全自定义，还可以重写一个，参考我的另一篇博文：http://blog.sina.com.cn/s/blog_71d4414d0100yu6k.html
//                    'header'=>'转往分页',//定义的文字将显示在pager的最前面
//                     'footer'=>'1',//定义的文字将显示在pager的最后面
//                    'firstPageLabel'=>'首页',//定义首页按钮的显示文字
//                    'lastPageLabel'=>'尾页',//定义末页按钮的显示文字
//                    'nextPageLabel'=>'下一页',//定义下一页按钮的显示文字
//                    'prevPageLabel'=>'前一页',//定义上一页按钮的显示文字
//                    //关于分页器这个array，具体还有很多属性，可参考CLinkPager的API
//                    'htmlOptions'=>array('calss'=>'pagination')
//                    ),
                'columns' => array(
                    array(
                        'name' => 'id',
                         'value' => '$data->id',
                       // 'htmlOptions' =>array('style'=>'width:10px;'),
                        //'filter'=>FALSE
                    ),
                     array(
                        'name' => 'name',
                        'header'=>'名称',
                        'value' => '$data->name',
                       // 'htmlOptions' =>array('style'=>'width:80px;'),
                    ),
                     array(
                        'name' => 'prov_id',
                        'header'=>'地区',
                        'value' => '$data->Area->name',
                        'filter'=>  CHtml::dropDownList('School[prov_id]','',CHtml::listData(Area::model()->findAllByAttributes(array('grade'=>1)),'id', 'name'),array(
                            'empty'=>'全部'
                        ))
                        //'htmlOptions' =>array('style'=>'width:20px;'),
                    ),
                    
                    array(
                        'name' => 'type_id',
                        'header'=>'学院类型',
                        'value' => '$data->type_id?$data->Type->name:"未知"',
                        'filter'=> CHtml::listData(Type::model()->findAllByAttributes(array('sign'=>1)),'id', 'name'),
                       // 'htmlOptions' =>array('style'=>'width:80px;'),
                    ),
                    
                     array(
                        'name' => 'initials',
                        'header'=>'学院首字母',
                        'value' => '$data->initials',
                       
                       // 'htmlOptions' =>array('style'=>'width:80px;'),
                    ),
                    
                       array(
                        'name' => 'domain',
                        'header'=>'二级域名',
                        'value' => '$data->domain',
                       
                       // 'htmlOptions' =>array('style'=>'width:80px;'),
                    ),
                      
                    array(
                   'header' => '操作',
                   'class' => 'bootstrap.widgets.TbButtonColumn',

                   'template' =>'{edit}|{delete}',

                   //'htmlOptions' => array('style' => 'width:100px'),
                   'buttons' => array(               
                       'edit'=>array(
                            'label' => '修改',
                             'url' => 'Yii::app()->createUrl("xyhadm/college/edit",
                                   array(
                                           "id"=>$data->id,
                                        ))',
                           'options'=>array(
                               'class'=>'label label-success',
                               'data-toggle'=>'modal',
                               'data-target'=>'#edit',
                               
                               )
 
                       ),
                       'delete'=>array(
                           'label' =>'删除',
                           'options'=>array(
                                'class'=>'label label-danger'
                           )
                           
                       ),
                       ),        
                   ),
                   
               
               ),
                
            ));
            
             Yii::app()->clientScript->registerScript('re-install-date-picker',"
            function reinstallDatePicker(id, data){ 
                $('#datepicker_for_due_date').datepicker(jQuery.extend(jQuery.datepicker.regional['en'],{'dateFormat':'yy-mm-dd'}));//
               
}");
 
            ?> 
                </div>
                        
                        
               </div>    
            </div>
</div>

<!-- 查看 -->

<div class="modal fade" style="display: none;" style="width: 1050px; margin: -10px 0 0 -450px;" id="view"  tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
   <div class="modal-dialog">
        <div class="modal-content" id="prepaidData-content" style="width: 1050px; margin: -10px 0 0 -450px;">
        
            
        </div>      
    </div>  
</div>

<!-- 修改 -->

<div class="modal fade" style="display: none;" style="width: 1050px; margin: -10px 0 0 -450px;" id="edit"  tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
   <div class="modal-dialog">
        <div class="modal-content" id="prepaidData-content" style="width: 1050px; margin: -10px 0 0 -450px;">
        
            
        </div>      
    </div>  
</div>





<!-- 添加 -->
<div class="modal fade" id="modalAdd"  style="display: none;" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
   <div class="modal-dialog">
        <div class="modal-content" id="prepaidData-content">
                 <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
                        <h3>学院添加</h3>
                </div>

            <div class="modal-body">
                
                
                <div class="control-group">
                    <label class="control-label">学院名称</label>
                    <div class="controls">
                        <input type="text" class="m-wrap small" name="School[name]" value="sss" id="School_add_name">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">地区</label>
                    <div class="controls">
                        <?php echo  CHtml::dropDownList('School[add_prov_id]','',CHtml::listData(Area::model()->findAllByAttributes(array('grade'=>1)),'id', 'name'))
                        ?>
                    </div>
                </div>
                
                <div class="control-group">
                    <label class="control-label">二级域名</label>
                    <div class="controls">
                       
                        <input type="text" class="m-wrap" placeholder="二级域名" id ="School_domain" name="School[domain]" ></input>

                    </div>
                  </div>
                
                <div class="control-group">
                    <label class="control-label">学院类型</label>
                    <div class="controls">
                        <?php echo  CHtml::dropDownList('School[add_type_id]','',CHtml::listData(Type::model()->findAllByAttributes(array('sign'=>1)),'id', 'name'))
                        ?>
                    </div>
                </div>
                
            </div>
             
            <div class="modal-footer">
            
            <?php
echo CHtml::ajaxSubmitButton('确定添加',Yii::app()->createUrl(Yii::app()->params['adminUrl'].'/college/add'),
                    array(  
                        'type'=>'POST',                     
                       'data' => 'js:{"School_name":$("#School_add_name").val(),'
                        . '"School_prov_id":$("#School_add_prov_id").val(),'
                        . '"School_type_id":$("#School_add_type_id").val(),'
                        . '"School_domain":$("#School_domain").val()'
                        . '}',
                        'success'=>'js:function(data){ 
                            if(data){
                                   alert("学院添加成功！");
                                   $("#table-school").yiiGridView("update");
                                   $("#modalAdd").modal("hide");
                            } 
                            else{
                                   alert("添加失败！");  
                                   $("#modalAdd").modal("hide");
                            }
                        }',   
                        'error'=>'js:function(){alert("添加失败");}'
                    ),array('class'=>'btn btn-info','id'=>'Submit_payment'));
                ?>
            </div>  
        </div>      
    </div>  
</div>




<script type="text/javascript">



 function is_status(id,status){
       if(status ==2){
           $.fn.yiiGridView.update('table-breaking',{
            type:'POST',
            url:$(this).attr('href'), 
             data:{'id':id,'status':status},
        });
        
       }else{
           alert('已采纳')
           return false;
       }
    }


$('#view').on('hidden.bs.modal',function(e){
    $('div.modal-backdrop.fade.in').remove();
     history.go(0);
});


$('#edit').on('hidden.bs.modal',function(e){
    $('div.modal-backdrop.fade.in').remove();
     history.go(0);
});




</script>